/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managerBeans;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ApplicationScoped;

/**
 *
 * @author HOANG ANH
 */
@ManagedBean
@ApplicationScoped
public class ProductBean {

    private List<String> productList;

    public List<String> getProductList() {
        return productList;
    }

    public void setProductList(List<String> productList) {
        this.productList = productList;
    }

    public List<String> complete(String query) {
        List<String> result = new ArrayList<String>();
        for (int i = 0; i < productList.size(); i++) {
            String product = productList.get(i);
            if (product.toLowerCase().startsWith(query.toLowerCase())) {
                result.add(product);
            }
        }
        return result;
    }

    /** Creates a new instance of ProductBean */
    public ProductBean() {
        productList = new ArrayList();
        productList.add("Coca cola");
        productList.add("Pepsi");
        productList.add("Pho");
        productList.add("Bun cha");
        productList.add("Guchi");
        productList.add("Obama");
        productList.add("Binladen");
        productList.add("Aptech");
        productList.add("Toyota");
        productList.add("Alibaba");
    }

    private Date today;

    public Date getToday() {
        return new Date();
    }

    public void setToday(Date today) {
        this.today = today;
    }
}
